home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / appc / ping.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-12  |  29.9 KB  |  878 lines

  1. VERSION 2.00
  2. Begin Form frmPing 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Ping!"
  6.    ClientHeight    =   4890
  7.    ClientLeft      =   2475
  8.    ClientTop       =   1305
  9.    ClientWidth     =   4515
  10.    FillColor       =   &H0000FF00&
  11.    FillStyle       =   0  'Solid
  12.    Height          =   5295
  13.    Icon            =   PING.FRX:0000
  14.    Left            =   2415
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    Picture         =   PING.FRX:0302
  19.    ScaleHeight     =   326
  20.    ScaleMode       =   3  'Pixel
  21.    ScaleWidth      =   301
  22.    Top             =   960
  23.    Width           =   4635
  24.    Begin CommandButton cmdExit 
  25.       Cancel          =   -1  'True
  26.       Caption         =   "E&xit"
  27.       FontBold        =   0   'False
  28.       FontItalic      =   0   'False
  29.       FontName        =   "MS Sans Serif"
  30.       FontSize        =   8.25
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   375
  34.       Left            =   3360
  35.       TabIndex        =   1
  36.       Top             =   4440
  37.       Width           =   975
  38.    End
  39.    Begin CommandButton cmdPing 
  40.       Caption         =   "&Ping"
  41.       Default         =   -1  'True
  42.       FontBold        =   0   'False
  43.       FontItalic      =   0   'False
  44.       FontName        =   "MS Sans Serif"
  45.       FontSize        =   8.25
  46.       FontStrikethru  =   0   'False
  47.       FontUnderline   =   0   'False
  48.       Height          =   375
  49.       Left            =   2280
  50.       TabIndex        =   0
  51.       Top             =   4440
  52.       Width           =   975
  53.    End
  54.    Begin Frame fraTrans 
  55.       BackColor       =   &H00FFFFFF&
  56.       Caption         =   "Transaction Options"
  57.       Height          =   3195
  58.       Left            =   2220
  59.       TabIndex        =   23
  60.       Top             =   1200
  61.       Width           =   2175
  62.       Begin TextBox txtAttempts 
  63.          FontBold        =   0   'False
  64.          FontItalic      =   0   'False
  65.          FontName        =   "MS Sans Serif"
  66.          FontSize        =   8.25
  67.          FontStrikethru  =   0   'False
  68.          FontUnderline   =   0   'False
  69.          Height          =   285
  70.          Left            =   960
  71.          TabIndex        =   17
  72.          TabStop         =   0   'False
  73.          Top             =   1800
  74.          Width           =   735
  75.       End
  76.       Begin TextBox txtSend 
  77.          FontBold        =   0   'False
  78.          FontItalic      =   0   'False
  79.          FontName        =   "MS Sans Serif"
  80.          FontSize        =   8.25
  81.          FontStrikethru  =   0   'False
  82.          FontUnderline   =   0   'False
  83.          Height          =   285
  84.          Left            =   60
  85.          TabIndex        =   15
  86.          Text            =   "a"
  87.          Top             =   1260
  88.          Width           =   735
  89.       End
  90.       Begin TextBox txtReceived 
  91.          FontBold        =   0   'False
  92.          FontItalic      =   0   'False
  93.          FontName        =   "MS Sans Serif"
  94.          FontSize        =   8.25
  95.          FontStrikethru  =   0   'False
  96.          FontUnderline   =   0   'False
  97.          Height          =   285
  98.          Left            =   60
  99.          TabIndex        =   16
  100.          Top             =   1800
  101.          Width           =   735
  102.       End
  103.       Begin TextBox txtBufSize 
  104.          FontBold        =   0   'False
  105.          FontItalic      =   0   'False
  106.          FontName        =   "MS Sans Serif"
  107.          FontSize        =   8.25
  108.          FontStrikethru  =   0   'False
  109.          FontUnderline   =   0   'False
  110.          Height          =   285
  111.          Left            =   60
  112.          TabIndex        =   13
  113.          Text            =   "271"
  114.          Top             =   480
  115.          Width           =   795
  116.       End
  117.       Begin CheckBox chkConfirm 
  118.          BackColor       =   &H00FFFFFF&
  119.          Caption         =   "Enable Confirmation"
  120.          FontBold        =   0   'False
  121.          FontItalic      =   0   'False
  122.          FontName        =   "MS Sans Serif"
  123.          FontSize        =   8.25
  124.          FontStrikethru  =   0   'False
  125.          FontUnderline   =   0   'False
  126.          Height          =   255
  127.          Left            =   60
  128.          TabIndex        =   14
  129.          Top             =   780
  130.          Width           =   1815
  131.       End
  132.       Begin Shape shpReset 
  133.          BackColor       =   &H00FFFFFF&
  134.          FillColor       =   &H00FFFFFF&
  135.          FillStyle       =   0  'Solid
  136.          Height          =   195
  137.          Left            =   60
  138.          Shape           =   3  'Circle
  139.          Top             =   2400
  140.          Width           =   135
  141.       End
  142.       Begin Label zlbl 
  143.          BackColor       =   &H00FFFFFF&
  144.          Caption         =   "Reset State"
  145.          FontBold        =   0   'False
  146.          FontItalic      =   0   'False
  147.          FontName        =   "MS Sans Serif"
  148.          FontSize        =   8.25
  149.          FontStrikethru  =   0   'False
  150.          FontUnderline   =   0   'False
  151.          Height          =   255
  152.          Index           =   1
  153.          Left            =   240
  154.          TabIndex        =   30
  155.          Top             =   2400
  156.          Width           =   915
  157.       End
  158.       Begin Label zlbl 
  159.          BackColor       =   &H00FFFFFF&
  160.          Caption         =   "Partner Wishes To Send"
  161.          FontBold        =   0   'False
  162.          FontItalic      =   0   'False
  163.          FontName        =   "MS Sans Serif"
  164.          FontSize        =   8.25
  165.          FontStrikethru  =   0   'False
  166.          FontUnderline   =   0   'False
  167.          Height          =   255
  168.          Index           =   3
  169.          Left            =   240
  170.          TabIndex        =   27
  171.          Top             =   2880
  172.          Width           =   1875
  173.       End
  174.       Begin Shape shpPartnerWishesToSend 
  175.          BackColor       =   &H00FFFFFF&
  176.          FillColor       =   &H00FFFFFF&
  177.          FillStyle       =   0  'Solid
  178.          Height          =   195
  179.          Left            =   60
  180.          Shape           =   3  'Circle
  181.          Top             =   2880
  182.          Width           =   135
  183.       End
  184.       Begin Label zlbl 
  185.          BackColor       =   &H00FFFFFF&
  186.          Caption         =   "Receive State"
  187.          FontBold        =   0   'False
  188.          FontItalic      =   0   'False
  189.          FontName        =   "MS Sans Serif"
  190.          FontSize        =   8.25
  191.          FontStrikethru  =   0   'False
  192.          FontUnderline   =   0   'False
  193.          Height          =   255
  194.          Index           =   0
  195.          Left            =   240
  196.          TabIndex        =   29
  197.          Top             =   2160
  198.          Width           =   1215
  199.       End
  200.       Begin Shape shpReceiving 
  201.          BackColor       =   &H00FFFFFF&
  202.          FillColor       =   &H00FFFFFF&
  203.          FillStyle       =   0  'Solid
  204.          Height          =   195
  205.          Left            =   60
  206.          Shape           =   3  'Circle
  207.          Top             =   2160
  208.          Width           =   135
  209.       End
  210.       Begin Label zlbl 
  211.          BackColor       =   &H00FFFFFF&
  212.          Caption         =   "Send State"
  213.          FontBold        =   0   'False
  214.          FontItalic      =   0   'False
  215.          FontName        =   "MS Sans Serif"
  216.          FontSize        =   8.25
  217.          FontStrikethru  =   0   'False
  218.          FontUnderline   =   0   'False
  219.          Height          =   255
  220.          Index           =   2
  221.          Left            =   240
  222.          TabIndex        =   28
  223.          Top             =   2640
  224.          Width           =   915
  225.       End
  226.       Begin Shape shpSending 
  227.          BackColor       =   &H00FFFFFF&
  228.          FillColor       =   &H00FFFFFF&
  229.          FillStyle       =   0  'Solid
  230.          Height          =   195
  231.          Left            =   60
  232.          Shape           =   3  'Circle
  233.          Top             =   2640
  234.          Width           =   135
  235.       End
  236.       Begin Label zlbl 
  237.          BackColor       =   &H00FFFFFF&
  238.          Caption         =   "Attempts:"
  239.          FontBold        =   0   'False
  240.          FontItalic      =   0   'False
  241.          FontName        =   "MS Sans Serif"
  242.          FontSize        =   8.25
  243.          FontStrikethru  =   0   'False
  244.          FontUnderline   =   0   'False
  245.          ForeColor       =   &H00000000&
  246.          Height          =   195
  247.          Index           =   4
  248.          Left            =   960
  249.          TabIndex        =   26
  250.          Top             =   1620
  251.          Width           =   795
  252.       End
  253.       Begin Label zlbl 
  254.          BackColor       =   &H00FFFFFF&
  255.          Caption         =   "Send:"
  256.          FontBold        =   0   'False
  257.          FontItalic      =   0   'False
  258.          FontName        =   "MS Sans Serif"
  259.          FontSize        =   8.25
  260.          FontStrikethru  =   0   'False
  261.          FontUnderline   =   0   'False
  262.          ForeColor       =   &H00000000&
  263.          Height          =   195
  264.          Index           =   6
  265.          Left            =   60
  266.          TabIndex        =   18
  267.          Top             =   1080
  268.          Width           =   795
  269.       End
  270.       Begin Label zlbl 
  271.          BackColor       =   &H00FFFFFF&
  272.          Caption         =   "Received:"
  273.          FontBold        =   0   'False
  274.          FontItalic      =   0   'False
  275.          FontName        =   "MS Sans Serif"
  276.          FontSize        =   8.25
  277.          FontStrikethru  =   0   'False
  278.          FontUnderline   =   0   'False
  279.          ForeColor       =   &H00000000&
  280.          Height          =   195
  281.          Index           =   5
  282.          Left            =   60
  283.          TabIndex        =   19
  284.          Top             =   1620
  285.          Width           =   795
  286.       End
  287.       Begin Label zlbl 
  288.          BackColor       =   &H00FFFFFF&
  289.          Caption         =   "Buffer Size:"
  290.          FontBold        =   0   'False
  291.          FontItalic      =   0   'False
  292.          FontName        =   "MS Sans Serif"
  293.          FontSize        =   8.25
  294.          FontStrikethru  =   0   'False
  295.          FontUnderline   =   0   'False
  296.          ForeColor       =   &H00000000&
  297.          Height          =   195
  298.          Index           =   7
  299.          Left            =   60
  300.          TabIndex        =   24
  301.          Top             =   300
  302.          Width           =   975
  303.       End
  304.    End
  305.    Begin Frame fraPing 
  306.       BackColor       =   &H00FFFFFF&
  307.       Caption         =   "Ping Options"
  308.       Height          =   3615
  309.       Left            =   120
  310.       TabIndex        =   22
  311.       Top             =   1200
  312.       Width           =   2055
  313.       Begin CheckBox chkPing 
  314.          BackColor       =   &H00FFFFFF&
  315.          Caption         =   "Receive"
  316.          FontBold        =   0   'False
  317.          FontItalic      =   0   'False
  318.          FontName        =   "MS Sans Serif"
  319.          FontSize        =   8.25
  320.          FontStrikethru  =   0   'False
  321.          FontUnderline   =   0   'False
  322.          Height          =   255
  323.          Index           =   5
  324.          Left            =   60
  325.          TabIndex        =   5
  326.          Top             =   1800
  327.          Value           =   1  'Checked
  328.          Width           =   1395
  329.       End
  330.       Begin CheckBox chkPing 
  331.          BackColor       =   &H00FFFFFF&
  332.          Caption         =   "Request To Send"
  333.          FontBold        =   0   'False
  334.          FontItalic      =   0   'False
  335.          FontName        =   "MS Sans Serif"
  336.          FontSize        =   8.25
  337.          FontStrikethru  =   0   'False
  338.          FontUnderline   =   0   'False
  339.          Height          =   255
  340.          Index           =   8
  341.          Left            =   60
  342.          TabIndex        =   10
  343.          Top             =   2700
  344.          Width           =   1755
  345.       End
  346.       Begin CheckBox chkPing 
  347.          BackColor       =   &H00FFFFFF&
  348.          Caption         =   "Query State"
  349.          FontBold        =   0   'False
  350.          FontItalic      =   0   'False
  351.          FontName        =   "MS Sans Serif"
  352.          FontSize        =   8.25
  353.          FontStrikethru  =   0   'False
  354.          FontUnderline   =   0   'False
  355.          Height          =   255
  356.          Index           =   7
  357.          Left            =   60
  358.          TabIndex        =   9
  359.          Top             =   2400
  360.          Width           =   1755
  361.       End
  362.       Begin CheckBox chkPing 
  363.          BackColor       =   &H00FFFFFF&
  364.          Caption         =   "Prepare To Receive"
  365.          FontBold        =   0   'False
  366.          FontItalic      =   0   'False
  367.          FontName        =   "MS Sans Serif"
  368.          FontSize        =   8.25
  369.          FontStrikethru  =   0   'False
  370.          FontUnderline   =   0   'False
  371.          Height          =   255
  372.          Index           =   4
  373.          Left            =   60
  374.          TabIndex        =   4
  375.          Top             =   1500
  376.          Value           =   1  'Checked
  377.          Width           =   1755
  378.       End
  379.       Begin CheckBox chkPing 
  380.          BackColor       =   &H00FFFFFF&
  381.          Caption         =   "Flush Buffer"
  382.          FontBold        =   0   'False
  383.          FontItalic      =   0   'False
  384.          FontName        =   "MS Sans Serif"
  385.          FontSize        =   8.25
  386.          FontStrikethru  =   0   'False
  387.          FontUnderline   =   0   'False
  388.          Height          =   255
  389.          Index           =   3
  390.          Left            =   60
  391.          TabIndex        =   8
  392.          Top             =   1200
  393.          Width           =   1515
  394.       End
  395.       Begin CheckBox chkPing 
  396.          BackColor       =   &H00FFFFFF&
  397.          Caption         =   "Send Confirm Reply"
  398.          FontBold        =   0   'False
  399.          FontItalic      =   0   'False
  400.          FontName        =   "MS Sans Serif"
  401.          FontSize        =   8.25
  402.          FontStrikethru  =   0   'False
  403.          FontUnderline   =   0   'False
  404.          Height          =   255
  405.          Index           =   6
  406.          Left            =   60
  407.          TabIndex        =   7
  408.          Top             =   2100
  409.          Width           =   1935
  410.       End
  411.       Begin CheckBox chkPing 
  412.          BackColor       =   &H00FFFFFF&
  413.          Caption         =   "Send Error"
  414.          FontBold        =   0   'False
  415.          FontItalic      =   0   'False
  416.          FontName        =   "MS Sans Serif"
  417.          FontSize        =   8.25
  418.          FontStrikethru  =   0   'False
  419.          FontUnderline   =   0   'False
  420.          Height          =   255
  421.          Index           =   9
  422.          Left            =   60
  423.          TabIndex        =   11
  424.          Top             =   3000
  425.          Width           =   1335
  426.       End
  427.       Begin CheckBox chkPing 
  428.          BackColor       =   &H00FFFFFF&
  429.          Caption         =   "Allocate"
  430.          FontBold        =   0   'False
  431.          FontItalic      =   0   'False
  432.          FontName        =   "MS Sans Serif"
  433.          FontSize        =   8.25
  434.          FontStrikethru  =   0   'False
  435.          FontUnderline   =   0   'False
  436.          Height          =   255
  437.          Index           =   0
  438.          Left            =   60
  439.          TabIndex        =   2
  440.          Top             =   300
  441.          Value           =   1  'Checked
  442.          Width           =   975
  443.       End
  444.       Begin CheckBox chkPing 
  445.          BackColor       =   &H00FFFFFF&
  446.          Caption         =   "Send"
  447.          FontBold        =   0   'False
  448.          FontItalic      =   0   'False
  449.          FontName        =   "MS Sans Serif"
  450.          FontSize        =   8.25
  451.          FontStrikethru  =   0   'False
  452.          FontUnderline   =   0   'False
  453.          Height          =   255
  454.          Index           =   1
  455.          Left            =   60
  456.          TabIndex        =   3
  457.          Top             =   600
  458.          Value           =   1  'Checked
  459.          Width           =   1395
  460.       End
  461.       Begin CheckBox chkPing 
  462.          BackColor       =   &H00FFFFFF&
  463.          Caption         =   "Deallocate"
  464.          FontBold        =   0   'False
  465.          FontItalic      =   0   'False
  466.          FontName        =   "MS Sans Serif"
  467.          FontSize        =   8.25
  468.          FontStrikethru  =   0   'False
  469.          FontUnderline   =   0   'False
  470.          Height          =   255
  471.          Index           =   10
  472.          Left            =   60
  473.          TabIndex        =   12
  474.          Top             =   3300
  475.          Value           =   1  'Checked
  476.          Width           =   1155
  477.       End
  478.       Begin CheckBox chkPing 
  479.          BackColor       =   &H00FFFFFF&
  480.          Caption         =   "Request Confirm"
  481.          FontBold        =   0   'False
  482.          FontItalic      =   0   'False
  483.          FontName        =   "MS Sans Serif"
  484.          FontSize        =   8.25
  485.          FontStrikethru  =   0   'False
  486.          FontUnderline   =   0   'False
  487.          Height          =   255
  488.          Index           =   2
  489.          Left            =   60
  490.          TabIndex        =   6
  491.          Top             =   900
  492.          Value           =   1  'Checked
  493.          Width           =   1515
  494.       End
  495.    End
  496.    Begin Label lblMsg 
  497.       BackStyle       =   0  'Transparent
  498.       FontBold        =   0   'False
  499.       FontItalic      =   0   'False
  500.       FontName        =   "MS Sans Serif"
  501.       FontSize        =   8.25
  502.       FontStrikethru  =   0   'False
  503.       FontUnderline   =   0   'False
  504.       Height          =   255
  505.       Left            =   60
  506.       TabIndex        =   25
  507.       Top             =   120
  508.       Width           =   3435
  509.    End
  510.    Begin Label lblPC 
  511.       BackColor       =   &H00FFFFFF&
  512.       Caption         =   "PC"
  513.       FontBold        =   0   'False
  514.       FontItalic      =   0   'False
  515.       FontName        =   "MS Sans Serif"
  516.       FontSize        =   8.25
  517.       FontStrikethru  =   0   'False
  518.       FontUnderline   =   0   'False
  519.       ForeColor       =   &H000000FF&
  520.       Height          =   255
  521.       Left            =   120
  522.       TabIndex        =   21
  523.       Top             =   1020
  524.       Width           =   1185
  525.    End
  526.    Begin Label lblSystem 
  527.       Alignment       =   1  'Right Justify
  528.       BackColor       =   &H00FFFFFF&
  529.       Caption         =   "AS/400"
  530.       FontBold        =   0   'False
  531.       FontItalic      =   0   'False
  532.       FontName        =   "MS Sans Serif"
  533.       FontSize        =   8.25
  534.       FontStrikethru  =   0   'False
  535.       FontUnderline   =   0   'False
  536.       ForeColor       =   &H00FF0000&
  537.       Height          =   255
  538.       Left            =   1470
  539.       TabIndex        =   20
  540.       Top             =   1020
  541.       Width           =   2925
  542.    End
  543.    Begin Image imgPingBack 
  544.       Height          =   480
  545.       Left            =   3300
  546.       Picture         =   PING.FRX:5944
  547.       Top             =   450
  548.       Visible         =   0   'False
  549.       Width           =   210
  550.    End
  551.    Begin Image imgPingOut 
  552.       Height          =   240
  553.       Left            =   570
  554.       Picture         =   PING.FRX:5F7E
  555.       Top             =   570
  556.       Visible         =   0   'False
  557.       Width           =   240
  558.    End
  559. Option Explicit
  560.  ' Constants:
  561.   Const nTRAN_SIZE = 1                      ' transaction size
  562.  ' Variables:
  563.   Dim bCAPartnerWishesToSend As Integer      ' partner wishes to send
  564.   Dim lCAConvId              As Long         ' conversation ID
  565.   Dim nCArc                  As Integer      ' API return code
  566.   Dim nCAReadAttempts        As Integer      ' number of read attempts
  567.   Dim nCASyncLvl             As Integer      ' synchronization level
  568.   Dim nCAWhatRcvd            As Integer      ' what is being sent back
  569.   Dim nPartnerMAX            As Integer      ' maximum read attempts
  570.   Dim nRC                    As Integer      ' return code
  571.   Dim sCAData                As String       ' data
  572.   Dim sCADataBlock           As String       ' data block
  573.   Dim sCALocalLU             As String       ' local LU ("PC") name
  574.   Dim sCAModeName            As String       ' mode name ("QPCSUPP")
  575.   Dim sCASystem              As String       ' AS/400 name
  576.   Dim sCAUserID              As String       ' AS/400 user ID
  577.   Dim sPartnerICF            As String       ' ICF program device
  578.   Dim sPartnerLIB            As String       ' partner library
  579.   Dim sPartnerPGM            As String       ' partner program
  580.   Dim sPartnerSYS            As String       ' partner system
  581. Sub cmdExit_Click ()
  582.   Unload Me
  583. End Sub
  584. Sub cmdPing_Click ()
  585.  ' Description:
  586.  '  PING
  587.  ' Variables:
  588.   Dim sPIP            As String   ' allocate PIP string
  589.   ReDim asPIP(1 To 1) As String   ' PIP parameters
  590.   ' clear any previous
  591.   ' messages and indicators
  592.   lblMsg = gsEMPTY
  593.   nCArc = 0
  594.   ' do audio and graphics
  595.   ' for PING out from PC
  596.   Call PingOut
  597.   ' if allocating and no active conversation then
  598.   If chkPing(0).Value = CHECKED And lCAConvId = 0 Then
  599.     ' format PIP data
  600.     asPIP(1) = Left$(sPartnerICF & Space$(10), 10)
  601.     sPIP = zzCAFormattedPIP(Me.hWnd, asPIP())
  602.     ' allocate ("start") the conversation
  603.     ' without or with confirmation enabled
  604.     If chkConfirm = False Then
  605.       lCAConvId = zzCAConvStart(Me.hWnd, Val(txtBufSize), sPartnerSYS, sPartnerLIB & "/" & sPartnerPGM, sPIP, nCArc)
  606.     Else
  607.       lCAConvId = zzCAConvStartConfirm(Me.hWnd, Val(txtBufSize), sPartnerSYS, sPartnerLIB & "/" & sPartnerPGM, sPIP, nCArc)
  608.     End If
  609.     ' update flags
  610.     Call SetStateAndSendFlags
  611.     ' if error then exit routine
  612.     If lCAConvId = 0 Then Exit Sub
  613.     ' query conversation attributes
  614.     nCArc = zzCAQueryAttributes(Me.hWnd, lCAConvId, nCASyncLvl, sCAModeName, sCALocalLU, sCASystem, sCAUserID)
  615.     ' update local lu name
  616.     lblPC = sCALocalLU
  617.     ' turn off allocate option
  618.     chkPing(0).Value = UNCHECKED
  619.     chkPing(0).Enabled = False
  620.   End If
  621.   ' if sending then
  622.   If chkPing(1).Value = CHECKED Then
  623.     ' convert to EBCDIC
  624.     sCAData = zzCV_ASCIItoEBCDIC(Me.hWnd, String$(nTRAN_SIZE, txtSend))
  625.     ' send data
  626.     nCArc = zzCASend(Me.hWnd, lCAConvId, sCAData, nTRAN_SIZE, bCAPartnerWishesToSend)
  627.     ' update flags
  628.     Call SetStateAndSendFlags
  629.   End If
  630.   ' if sending confirmation request
  631.   If chkPing(2).Value = CHECKED Then
  632.     ' send confirmation request
  633.     nCArc = zzCASendConfirmRequest(Me.hWnd, lCAConvId, bCAPartnerWishesToSend)
  634.     ' update flags
  635.     Call SetStateAndSendFlags
  636.   End If
  637.   ' if flushing buffer then
  638.   If chkPing(3).Value = CHECKED Then
  639.     ' flush buffer
  640.     nCArc = zzCAFlush(Me.hWnd, lCAConvId)
  641.     ' update flags
  642.     Call SetStateAndSendFlags
  643.   End If
  644.   ' if preparing to receive then
  645.   If chkPing(4).Value = CHECKED Then
  646.     ' prepare to receive
  647.     nCArc = zzCATellReadyToReceive(Me.hWnd, lCAConvId)
  648.     ' update flags
  649.     Call SetStateAndSendFlags
  650.   End If
  651.   ' if receiving then
  652.   If chkPing(5).Value = CHECKED Then
  653.     ' clear fields
  654.     txtReceived = gsEMPTY        ' value returned
  655.     sCADataBlock = gsEMPTY       ' clear block
  656.     nCAReadAttempts = 0          ' counter
  657.     txtAttempts.Text = "0"       ' counter label
  658.     Do
  659.       ' receive data
  660.       nCArc = zzCAReceive(Me.hWnd, lCAConvId, nTRAN_SIZE, sCAData, nCAWhatRcvd, bCAPartnerWishesToSend)
  661.       ' increment counter of read attempts
  662.       nCAReadAttempts = nCAReadAttempts + 1
  663.       txtAttempts.Text = Format$(nCAReadAttempts)
  664.       If nCAReadAttempts > nPartnerMAX Then Exit Do
  665.       
  666.       ' give windows time
  667.       DoEvents
  668.       ' if error on receipt of data
  669.       If nCArc <> gnCA_OK Then
  670.       
  671.         ' if not "unsuccessful read" then update message
  672.         If nCArc <> gnCA_UNSUCCESSFUL Then Exit Do
  673.       
  674.       ' if no error
  675.       Else
  676.         ' if send requested by partner
  677.         ' this signals end of transmission
  678.         If nCAWhatRcvd = gnCA_RCVD_SEND Then
  679.           ' remove headers from data
  680.           sCADataBlock = zzCARemoveHeadersFromBlock(sCADataBlock, nTRAN_SIZE)
  681.           ' convert to ASCII
  682.           sCADataBlock = zzCV_EBCDICtoASCII(Me.hWnd, sCADataBlock)
  683.           
  684.           ' leave loop
  685.           Exit Do
  686.         ' add what returned to data block
  687.         Else
  688.           sCADataBlock = sCADataBlock & sCAData
  689.         End If
  690.       End If
  691.     Loop
  692.     ' place data into text box
  693.     txtReceived = sCADataBlock
  694.     ' update flags
  695.     Call SetStateAndSendFlags
  696.   End If
  697.   ' if answering confirmation request
  698.   If chkPing(6).Value = CHECKED Then
  699.     ' reply to confirmation request
  700.     nCArc = zzCASendConfirmReply(Me.hWnd, lCAConvId)
  701.     ' update flags
  702.     Call SetStateAndSendFlags
  703.   End If
  704.   ' if querying state then
  705.   If chkPing(7).Value = CHECKED Then
  706.     ' show message box that description state of conversation
  707.     MsgBox zzCAGetStateText(zzCAQueryState(Me.hWnd, lCAConvId), True), MB_ICONINFORMATION
  708.   End If
  709.   ' if requesting to send then
  710.   If chkPing(8).Value = CHECKED Then
  711.     ' request to send
  712.     nCArc = zzCATellWantToSend(Me.hWnd, lCAConvId)
  713.     ' update flags
  714.     Call SetStateAndSendFlags
  715.   End If
  716.   ' if sending error indication
  717.   If chkPing(9).Value = CHECKED Then
  718.     ' send error
  719.     nCArc = zzCASendError(Me.hWnd, lCAConvId, bCAPartnerWishesToSend)
  720.     ' update flags
  721.     Call SetStateAndSendFlags
  722.   End If
  723.   ' if deallocating and active conversation
  724.   If chkPing(10).Value = CHECKED Then
  725.     ' end conversation
  726.     nCArc = zzCAConvStopConfirm(Me.hWnd, lCAConvId, True)
  727.     ' update flags
  728.     Call SetStateAndSendFlags
  729.     ' if any unexpected error then exit routine
  730.     If nCArc <> gnCA_OK And nCArc <> gnCA_DEALLOC_ABEND_PROGRAM Then Exit Sub
  731.     ' no more active conversation
  732.     lCAConvId = 0
  733.     ' turn on allocate option
  734.     chkPing(0).Value = CHECKED
  735.     chkPing(0).Enabled = True
  736.   End If
  737.   ' do audio and graphics
  738.   ' for PING out from AS/400
  739.   ' if no errors occurred
  740.   If lblMsg = gsEMPTY Then Call PingBack
  741. End Sub
  742. Sub Form_Load ()
  743.   ' setup globals
  744.   Call zzSetGlobalVariables
  745.   ' center form
  746.   zzFormCenter Me
  747.   ' setup title
  748.   App.Title = Caption
  749.   ' setup INI file and section
  750.   nRC = zzINISetFile(App.Path & "\APPC.INI")
  751.   nRC = zzINISetSection("PING")
  752.   ' get AS/400 system
  753.   nRC = zzINIGetString("System", sPartnerSYS)
  754.   ' get AS/400 library
  755.   nRC = zzINIGetString("Library", sPartnerLIB)
  756.   ' get AS/400 program
  757.   nRC = zzINIGetString("Program", sPartnerPGM)
  758.   ' get AS/400 ICF device
  759.   nRC = zzINIGetString("Device", sPartnerICF)
  760.   ' get maximum read attempts
  761.   nRC = zzINIGetInteger("MaxAttempts", nPartnerMAX)
  762.   If sPartnerSYS = gsEMPTY Then
  763.     MsgBox "AS/400 system reference invalid. Check APPC.INI file for proper values."
  764.     End
  765.   ElseIf sPartnerLIB = gsEMPTY Then
  766.     MsgBox "AS/400 library reference invalid. Check APPC.INI file for proper values."
  767.     End
  768.   ElseIf sPartnerPGM <> "PINGRPG" Then
  769.     MsgBox "AS/400 program reference invalid. Check APPC.INI file for proper values."
  770.     End
  771.   ElseIf sPartnerICF <> "PINGICF" Then
  772.     MsgBox "AS/400 ICF device reference invalid. Check APPC.INI file for proper values."
  773.     End
  774.   ElseIf nPartnerMAX = 0 Then
  775.     MsgBox "APPC retry attempts setting invalid. Check APPC.INI file for proper values."
  776.     End
  777.   End If
  778.   ' display information
  779.   lblSystem = sPartnerSYS & "/" & sPartnerLIB & "/" & sPartnerPGM
  780.   ' no active conversation
  781.   lCAConvId = 0
  782.   ' if router not loaded then
  783.   If Not zzCARouterLoaded(Me.hWnd) Then
  784.     ' tell user of error
  785.     lblMsg = zzCAGetRCText(gnCA_ROUTER_NOT_INSTALLED, True)
  786.   End If
  787. End Sub
  788. Sub Form_Unload (Cancel As Integer)
  789.   ' if active conversation
  790.   If lCAConvId <> 0 Then
  791.     ' end conversation
  792.     nCArc = zzCAConvStopConfirm(Me.hWnd, lCAConvId, True)
  793.     ' if conversation not ended
  794.     If nCArc <> gnCA_OK Then MsgBox zzCAGetRCText(nCArc, True), MB_ICONSTOP
  795.   End If
  796.   ' end program
  797.   End
  798. End Sub
  799. Sub PingBack ()
  800.  ' Description:
  801.  '  Do audio and graphics stuff
  802.  '  that show a PING going from
  803.  '  AS/400 to PC.
  804.  ' Variables:
  805.   Dim nLoc As Integer
  806.   imgPingBack.Top = 30
  807.   imgPingBack.Left = 220
  808.   imgPingBack.Visible = True
  809.   For nLoc = 218 To 34 Step -2
  810.     imgPingBack.Left = nLoc
  811.   Next nLoc
  812.   imgPingBack.Visible = False
  813.   nLoc = zzWAVPlay(App.Path & "\pingbck.wav")
  814. End Sub
  815. Sub PingOut ()
  816.  ' Description:
  817.  '  Do audio and graphics stuff
  818.  '  that show a PING going from
  819.  '  PC to AS/400.
  820.  ' Variables:
  821.   Dim nLoc As Integer
  822.   imgPingOut.Top = 38
  823.   imgPingOut.Left = 38
  824.   imgPingOut.Visible = True
  825.   nLoc = zzWAVPlay(App.Path & "\pingout.wav")
  826.   For nLoc = 40 To 218 Step 2
  827.     imgPingOut.Left = nLoc
  828.   Next nLoc
  829.   imgPingOut.Visible = False
  830. End Sub
  831. Sub SetStateAndSendFlags ()
  832.  ' Description:
  833.  '  Set SEND and RECEIVE state flags
  834.  '  and whether the partner wishes to send
  835.   ' update message
  836.   lblMsg = zzCAGetRCText(nCArc, True)
  837.   ' is the conversation in RESET state
  838.   If zzCAQueryAmIReset(Me.hWnd, lCAConvId) Then
  839.     shpReset.FillColor = YELLOW
  840.   Else
  841.     shpReset.FillColor = WHITE
  842.   End If
  843.   ' is the conversation in SEND state
  844.   If zzCAQueryAmISending(Me.hWnd, lCAConvId) Then
  845.     shpSending.FillColor = GREEN
  846.   Else
  847.     shpSending.FillColor = WHITE
  848.   End If
  849.   ' is the conversation in RECEIVE state
  850.   If zzCAQueryAmIReceiving(Me.hWnd, lCAConvId) Then
  851.     shpReceiving.FillColor = RED
  852.   Else
  853.     shpReceiving.FillColor = WHITE
  854.   End If
  855.   ' has partner sent a REQUEST TO SEND
  856.   If bCAPartnerWishesToSend Then
  857.     shpPartnerWishesToSend.FillColor = BLACK
  858.   Else
  859.     shpPartnerWishesToSend.FillColor = WHITE
  860.   End If
  861. End Sub
  862. Sub txtAttempts_GotFocus ()
  863.   SendKeys "{TAB}"
  864. End Sub
  865. Sub txtBufSize_LostFocus ()
  866.   ' make sure a number
  867.   txtBufSize = Format$(Val(txtBufSize))
  868.   If txtBufSize = "0" Then txtBufSize = "271"
  869. End Sub
  870. Sub txtReceived_GotFocus ()
  871.   ' can't stop here
  872.   SendKeys "{Tab}"
  873. End Sub
  874. Sub txtSend_Change ()
  875.   ' one letter upper case allowed
  876.   txtSend = LCase$(Left$(txtSend, nTRAN_SIZE))
  877. End Sub
  878.